import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
    name: 'userStatus'
})
export class UserStatusPipe implements PipeTransform {
    transform(value: any, ...args: any[]): any {
        let result: string = '';

        if (value) {
            value = value.toString().toLowerCase();

            switch (value) {
                case 'active':
                    result = '<span class="label label-table label-success">正常</span>';
                    break;
                case 'disabled':
                    result = '<span class="label label-table label-inverse">Disabled</span>';
                    break;
                case 'suspended':
                    result = '<span class="label label-table label-danger">停用</span>';
                    break;
            }
        }

        return result;
    }
}